use super::*;

pub struct Call<F: FnMut() -> bool> {
    finished: bool,
    func: F,
}

impl<F> Call<F> where F: FnMut() -> bool {
    pub fn new(func: F) -> Box<Self> {
        Box::new(Self {
            finished: false,
            func,
        })
    }
}

impl<F> ITask for Call<F> where F: FnMut() -> bool {
    fn step(&mut self) {
        self.finished = (self.func)();
    }

    fn reset(&mut self) {
        self.finished = false;
    }

    fn is_finished(&self) -> bool {
        self.finished
    }
}